RISC OS 3.7 User Guide
The BASIC language operates within an environment provided by the computer's operating system. The operating system is responsible for controlling the devices available to the computer, such as the keyboard, the screen, and the filing system. For example, it is the operating system which reads each key you press and displays the appropriate character on the screen. Operating system commands can be entered directly from within BASIC by prefixing them with an asterisk (*).
If you want to find out more about the BBC BASIC programming language, you need the
On-line help is available within BASIC; just type HELP (in uppercase) for more information.
BASIC V is in the ROM and is almost identical to the BASIC V supplied with earlier versions of RISC OS. A small number of faults have been corrected.
BASIC VI is essentially the same as BASIC V, but it uses 8 bytes (or 64 bits) to store floating point numbers. BASIC V only uses 5 bytes, so it is slightly less accurate. The 8 byte representation used follows the IEEE standard. Unlike BASIC V, BASIC VI makes use of a hardware floating point unit if it is fitted.
BASIC
Press Return, and the BASIC V version and memory will be displayed on the screen.
BASIC can also be started from the New Task option on the Task Manager or from the command line (press F12).
BASIC VI is used by some applications (for example SciCalc) so it may get loaded into memory without you having to take any special action.
To start BASIC VI, display the Task manager menu (click Menu over the Acorn icon at the bottom righthand corner of the desktop). Choose the Task window option and then type the following:
System:Modules.BASIC64
Press Return, and the BASIC VI version and memory option will be displayed on the screen. (Note: You can't just type BASIC64, as the BASIC64 module is not in the library directory).
BASIC 64 can also be started from the New task option on the Task manager menu or from the command line (press F12).
BASIC files saved from both BASIC V and BASIC VI are the same and can be run using either BASIC.
QUIT
(which must be in uppercase) or type *Quit
.The TEXTLOAD command can load a file that is either a BASIC program, or a BASIC program that was saved as a text file. In the latter case, TEXTLOAD automatically renumbers the program. TEXTSAVE stores a BASIC program as a text file, and strips out the line numbers.
*BASIC [options]
The options control how the interpreter will behave when it starts, and when any program that it executes terminates. If no option is given, BASIC simply starts with a message of the form:
ARM BBC BASIC V version 1.05 (C) Acorn 1989
Starting with 643324 bytes free
The number of bytes free in the above message will depend on the amount of memory in your Next slot. The first line is also used for the default REPORT message, before any errors occur.
One of three options may follow the *BASIC command to cause a program to be loaded, and, optionally, executed automatically. Alternatively, you can use a program that is already loaded into memory by passing its address to the interpreter. Each of these possibilities is described in turn below.
In all cases where a program is specified, this may be a tokenised BASIC program, as created by a SAVE command, or a textual program, which will be tokenised (and possibly renumbered) automatically.
*BASIC -help
This command causes BASIC to print some help information describing the options documented here. Then BASIC starts as usual.
*BASIC [-chain] filename
If you give a filename after the *BASIC command, optionally preceded by the keyword -chain, then the named file is loaded and executed. When the program stops, BASIC enters immediate mode, as usual.
*BASIC -quit filename
This behaves in a similar way to the previous option. However, when the program terminates, BASIC quits automatically, returning to the environment from which the interpreter was originally called. If you have a variable BASIC$Crunch
defined, it also performs a CRUNCH %1111 on the program. This is the default action used by BASIC programs that are executed as * commands. In addition, the function QUIT returns TRUE if BASIC is called in this fashion.
*BASIC -load filename
This option causes the file to be loaded automatically, but not executed. BASIC remains in immediate mode, from where the program can be edited or executed as required.
*BASIC @start,end
This acts in a similar way to the -load form of the command. However, the program that is 'loaded' automatically is not in a file, but already in memory. Following the @ are two addresses. These give, in hexadecimal, the address of the start of the in-core program, and the address of the byte after the last one. The program is copied to PAGE and tokenised if necessary.
Note that the in-core address description is fixed format. It should be in the form:
@xxxxxxxx,xxxxxxxx
where x means a hexadecimal digit. Leading zeros must be supplied. The command line terminator character must come immediately after the last digit. No spaces are allowed.
*BASIC -chain @start,end
This behaves like the previous option, but the program is executed as well. When the program terminates, BASIC enters immediate mode.
*BASIC -quit @start,end
This option behaves as the previous one, but when the BASIC program terminates, BASIC automatically quits. The QUIT flag will return TRUE during the execution of the program.
*BASIC -quit shellProg
*BASIC @000ADF0C,000AE345
*BASIC -chain fred
This assumes that the BASIC64 module has been 'seen'. If not, you need to type
*System:Modules.BASIC64
If no option is given, BASIC VI simply starts with a message of the form:
ARM BBC BASIC VI version 1.05 (C) Acorn 1989 Starting with 581628 bytes free.
The number of bytes free in the above message will depend on the amount of free space in your Next slot.
*BASIC64 -quit shellProg
*BASIC64 @000ADF0C,000AE345
*BASIC64 -chain fred
If n is greater than 128, the background colour is set to colour n-128
As a function MODE gives the current screen mode.
MODE has been extended to take a pointer to a mode selector or a mode string. A mode selector is passed to OS_ScreenMode, whereas a mode string is passed to *WimpMode. The result is that if a program changes screen mode using a mode string, e.g. MODE "X800 Y600 C256 EX1 EY1", then when the program finishes that will be your desktop mode.
It should also be noted that the C/G option in the mode string is implemented by *WimpMode. Hence, MODE MODE will select a default palette mode for the given current mode depth. This means that if a grey mode is selected by MODE "X800 Y600 G256 EX1 EX1" then MODE MODE will revert back to the coloured palette.